import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from "@angular/router";
import {BasicService} from "../../unit/basic-service";
import {CertificateItem} from "../../modals/basic.modal";

@Component({
    selector: 'app-certificate-detail',
    templateUrl: './certificate-detail.page.html',
    styleUrls: ['./certificate-detail.page.scss'],
})
export class CertificateDetailPage implements OnInit {
    detailData: CertificateItem;
    currentType: string;

    constructor(private activateInfo: ActivatedRoute,
                private basicService: BasicService) {
    }

    ngOnInit() {
        this.activateInfo.queryParamMap.subscribe((res: any) => {
            if (res.params && res.params) {
                this.initData(res.params);
            }
        });
    }

    initData(params) {
        this.currentType = params.type;
        this.basicService.getData('zgzs/getdzzs',
            {id: params.id, type:params.type}).subscribe(res => {
            this.reGroupData(res);
        })
    }

    reGroupData(res){
        this.detailData =  res;
    }
}
